package com.seaboxdata.interfaceJob.queuing;

import com.alibaba.fastjson.JSONObject;
import com.seaboxdata.entity.BlockMonitoring;
import com.seaboxdata.entity.queuing.VwNetWork;
import com.seaboxdata.kafka.BaseStringKafkaProducer;
import com.seaboxdata.service.queuing.VwNetWorkService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
@Component
@Configuration
@Slf4j
public class VwNetWorkJob {
    @Value("${queuing.vwNetWork.Topic}")
    private String topic;
    @Autowired
    private BaseStringKafkaProducer baseStringKafkaProducer;
    @Autowired
    private VwNetWorkService vwNetWorkService;

 //   @Scheduled(cron = "${queuing.vwNetWork.Scheduled}")//每隔5分钟执行一次
//    public void VwNetWorkreadKafka(){
//        try {
//            List<VwNetWork> vwNetWorks = vwNetWorkService.list();
//            if (!CollectionUtils.isEmpty(vwNetWorks)) {
//                //写入kafka
//                Date date = new Date();
//                System.out.print("==========================================================");
//                for (VwNetWork vwNetWork : vwNetWorks) {
//                    //vwNetWork.setCjsj(date);
//                    baseStringKafkaProducer.sendMessageToKafka(JSONObject.toJSONString(vwNetWork), topic);
//                    System.out.println(vwNetWork.getId()+"===="+vwNetWork.getName()+"===="+date.getTime());
//                }
//                System.out.print("==========================================================");
//            }
//        } catch (Exception e) {
//            log.error("write blockMonitoring error");
//            e.printStackTrace();
//        }
//    }
}
